from django.urls import path, include, register_converter

from apps.users.views import UsernameCountView, RegisterView, LoginView, LogoutView, UserInfoView, SaveEmail, \
    EmailVerifView, AddAddress, ShowAddress, UpdateTitle, DelANDUpdateAddr, UpdatePwd
from utils.converters import UsernameConverter

register_converter(UsernameConverter, "uname")

urlpatterns = [
    path('usernames/<uname:username>/count/', UsernameCountView.as_view()),

    path('register/', RegisterView.as_view()),
    path('login/', LoginView.as_view()),
    path('logout/', LogoutView.as_view()),
    path('info/', UserInfoView.as_view()),
    path('emails/', SaveEmail.as_view()),
    path('emails/verification/<token_id>', EmailVerifView.as_view()),

    # 添加收货地址
    path('addresses/create/', AddAddress.as_view()),

    # 获取收货地址
    path('addresses/', ShowAddress.as_view()),

    # 跟新title
    path('addresses/<addr_id>/title/', UpdateTitle.as_view()),

    # 删除和更新收货地址
    path('addresses/<addr_id>/', DelANDUpdateAddr.as_view()),

    # 修改密码
    path('password/', UpdatePwd.as_view())
]
